//
//  BaseViewController.m
//  ArtMedia
//
//  Created by 程明 on 2018/9/27.
//  Copyright © 2018年 程明. All rights reserved.
//

#import "BaseViewController.h"
#import "BaseNavigationController.h"
#import "AppDelegate.h"
@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    [self setElement];
}

- (void)setElement {
    
    self.navigationController.navigationBar.hidden = YES;
    self.view.backgroundColor = [UIColor whiteColor];
}



//-(void)showMessageWithStr:(NSString*)str withType:(int)type
//{
//    switch (type) {
//        case 0:
//        {
//            [SVProgressHUD showInfoWithStatus:str];
//        }
//            break;
//        case 1:
//        {
//            [SVProgressHUD showSuccessWithStatus:str];
//        }
//            break;
//        case 2:
//        {
//            [SVProgressHUD showErrorWithStatus:str];
//        }
//            break;
//            
//        default:
//        {
//            [SVProgressHUD showWithStatus:str];
//        }
//            break;
//    }
//    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
//    [SVProgressHUD show];
//}
-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
}
#pragma  mark 横屏设置

//设置横屏
- (void)setOrientationLandscape {
    // 强制横屏
    [self forceOrientationLandscape];
    
    BaseNavigationController *nav = (BaseNavigationController *)self.navigationController;
    nav.interfaceOrientation = UIInterfaceOrientationLandscapeRight;
    //nav.interfaceOrientationMask = UIInterfaceOrientationMaskLandscapeRight;
    
    //强制翻转屏幕，Home键在右边。
    [[UIDevice currentDevice] setValue:@(UIInterfaceOrientationLandscapeRight) forKey:@"orientation"];
    //刷新
    [UIViewController attemptRotationToDeviceOrientation];
}

//强制横屏
- (void)forceOrientationLandscape{
    
    AppDelegate *appdelegate=(AppDelegate *)[UIApplication sharedApplication].delegate;
    appdelegate.isForceLandscape=YES;
    appdelegate.isForcePortrait=NO;
    [appdelegate application:[UIApplication sharedApplication] supportedInterfaceOrientationsForWindow:self.view.window];
}
//设置竖屏
- (void)setOrientationPortrait{
    //强制旋转竖屏
    [self forceOrientationPortrait];
//    BaseNavigationController *navi = (BaseNavigationController *)self.navigationController;
//    navi.interfaceOrientation = UIInterfaceOrientationPortrait;
    //navi.interfaceOrientationMask = UIInterfaceOrientationMaskPortrait;
    
    //设置屏幕的转向为竖屏
    [[UIDevice currentDevice] setValue:@(UIDeviceOrientationPortrait) forKey:@"orientation"];
    //刷新
    [UIViewController attemptRotationToDeviceOrientation];
}

//强制竖屏
- (void)forceOrientationPortrait{
    
    AppDelegate *appdelegate=(AppDelegate *)[UIApplication sharedApplication].delegate;
    appdelegate.isForcePortrait=YES;
    appdelegate.isForceLandscape=NO;
    [appdelegate application:[UIApplication sharedApplication] supportedInterfaceOrientationsForWindow:self.view.window];
}
@end
